﻿
<h3>新增菜品</h3>
<script src="~/js/vue.min.js"></script>
<script src="~/js/axios.min.js"></script>
<script src="~/js/qs.min.js"></script>
<script src="~/js/moment.js"></script>

@{
    ViewData["Title"] = "GetDishInfo";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style type="text/css">
    tr.change:hover {
        background-color: #00FF00
    }
</style>

<div class="row" id="mm">
    <table class="table table-bordered">
        <tr>
            <td>菜品名称</td>
            <td><input id="name" type="text"placeholder="请输入新菜品的名称"></td>
        </tr>
        <tr>
            <td>菜品价格</td>
            <td><input id="price" type="text"placeholder="请为新菜品定价"></td>
        </tr>
        <tr>
            <td>菜品类型</td>   
            <td><input id="leixing" type="text" placeholder="1为热菜 2 为凉菜 3 为汤"></td> 
        </tr>
        <tr>
            <td>菜品图片</td>
            <td><input id="picture" type="text"placeholder="请输入图片的路径"></td>
        </tr>
        <tr>
            <td>
                <input id="Button1" type="button" value="保存" v-on:click="AddDish" />
            </td>
            <td>
                <input id="Button1" type="button" value="重置" onclick="xx()" />
            </td>
        </tr>
    </table>
</div>



<script>
    //
    new Vue({
        el: "#mm",
        data() {
           
        },
       
        methods: {
            AddDish: function () {
                var m = {}
                m.DishName = $("#name").val();
                m.DishPrice = $("#price").val();
                m.DishLei = $("#leixing").val();
                m.DishPicture = $("#picture").val();
                axios
                    .post("/Dishs/AddDish", window.Qs.stringify(m))
                    .then(
                        function (i) {
                            if (i.data > 0) {
                                alert("添加成功");
                                location.href = "/Dishs/GetDishInfo";
                            }
                            else {
                                alert("添加失败");
                            }
                        }
                    )

            }
        }

    })
    function xx() {
        location.href = '/dishs/AddDishInfo'
    }
</script>

@*<script>
        var add = new Vue({
            el: "#mm",
            data: {
                dishesInfo:[]
            },
            methods: {
                adddish: function () {



                }

            }


        })
    </script>


    }*@



